﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Animation;
using System.Windows;

namespace DisplayBoardInfo.Server.Helpers
{
    class WPF
    {
        public static void FadeInAnimation(System.Windows.Controls.Control control, System.Windows.Controls.Control container)
        {
            DoubleAnimation anim = new DoubleAnimation();
            anim.From = 0;
            anim.To = 1;
            anim.Duration = new Duration(TimeSpan.FromSeconds(1));

            Storyboard myStoryboard = new Storyboard();
            myStoryboard.Children.Add(anim);
            Storyboard.SetTargetName(anim, control.Name);
            Storyboard.SetTargetProperty(anim, new PropertyPath(System.Windows.Controls.Control.OpacityProperty));

            myStoryboard.Begin(container);
        }

        public static void FadeOutAnimation(System.Windows.Controls.Control control, System.Windows.Controls.Control container)
        {
            DoubleAnimation anim = new DoubleAnimation();
            anim.From = 1;
            anim.To = 0;
            anim.Duration = new Duration(TimeSpan.FromSeconds(1));

            Storyboard myStoryboard = new Storyboard();
            myStoryboard.Children.Add(anim);
            Storyboard.SetTargetName(anim, control.Name);
            Storyboard.SetTargetProperty(anim, new PropertyPath(System.Windows.Controls.Control.OpacityProperty));

            myStoryboard.Begin(container);
        }
    }
}
